import os

if __name__ == '__main__':
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "p2020_2_10.settings")
    import django

    django.setup()
from App01 import models

# print(models.Publisher.objects.get(id=1).book_set.first().authors.filter(name__contains='李'))
# print(models.Book.objects.filter(id=1).values_list('publisher__name'))
# print(models.Publisher.objects.filter(id=1).values_list('book__authors__name'))
p1 = models.Publisher.objects.get(id=2)
p1.book_set.add(*models.Book.objects.filter(id=7))
